#ifndef COM_CONNECT_HPP
#define COM_CONNECT_HPP
#include <QDebug>
#include <QObject>
#include <QSerialPort>
#include <QSerialPortInfo>
#include <QString>
#include <qserialport.h>
#include <qtmetamacros.h>
#include <qtypes.h>

class ComConnect : public QObject {
  Q_OBJECT
public:
  explicit ComConnect(QObject *parent = nullptr);
  ~ComConnect();
public slots:
  void closeCom();
  bool initComPort(const QString& comPort, int index, bool is_connect, qint32 baudRate);
  Q_INVOKABLE QSerialPort *getSerialP();
  Q_INVOKABLE bool getConnectStatus();
  Q_INVOKABLE qint32 getBaudRate();
private:
  QSerialPort *serial;
  bool connect_status;
  qint32 baudRate;
};
#endif